package edu.qd.learn.newchapter.chapter_thread.day02;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author 布衣
 */
public class ImplementRunnable implements Runnable{

    @Override
    public void run() {
        System.out.println("开始==>"+Thread.currentThread().getName());
        System.out.println("11---<");
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("结束==>"+Thread.currentThread().getName());
    }

    public static void main(String[] args) {

        ExecutorService es = Executors.newFixedThreadPool(2);
        for (int i = 0; i < 10; i++) {
            Thread t1 = new Thread(new ImplementRunnable());
            t1.setName("线程"+i);
            es.execute(t1);
        }
        es.shutdown();

//        Thread t1 = new Thread(new ImplementRunnable());
//        t1.start();
//
//
//        //内部类
//        Thread t2 = new Thread(new Runnable() {
//            @Override
//            public void run() {
//
//            }
//        });
//
//        Thread t3 = new Thread(()->{
//            System.out.println("run===》");
//        });

    }


}
